package com.example.enums;

import java.util.Scanner;

public class EnumTest {
    public static void main(String[] args) {
        var in = new Scanner(System.in);
        String input = in.next().toUpperCase();
        Size size = Enum.valueOf(Size.class, input);
        System.out.println("size = " + size);
        System.out.println("Abbreviation = " + size.getAbbreviation());
        if(size == Size.EXRTA_LARGE){
            System.out.println("你选中的是超大号！");
        }
        System.out.println("枚举值索引为： " + size.ordinal());
        System.out.println("与 MEDIUM 比较结果：" + size.compareTo(Size.MEDIUM));
    }
}

enum Size {
    SMALL("S"), MEDIUM("M"), LARGE("L"), EXRTA_LARGE("XL");

    private Size(String abbreviation){
        this.abbreviation = abbreviation;
    }

    public String getAbbreviation() {
        return abbreviation;
    }

    String abbreviation;
}
